import 'package:flutter/material.dart';
import 'package:flutter_deer/account/models/user_score_deposit_entity.dart';
import 'package:flutter_deer/widgets/state_layout.dart';

class RechargeListProvider extends ChangeNotifier {

  UserScoreDepositPageEntity? _depositPage;
  List<UserScoreDepositEntity>? _list = [];
  StateType? _stateType = StateType.loading;
  int? _currentPage = 1;

  UserScoreDepositPageEntity? get depositPage => _depositPage;
  int? get total => _depositPage!.total;
  int? get current => _depositPage!.current;
  List<UserScoreDepositEntity>? get records => _depositPage!.records;
  List<UserScoreDepositEntity>? get list => _list;
  bool? get hasMore => _depositPage!.current!<_depositPage!.pages!;
  StateType? get stateType => _stateType;
  int? get currentPage => _currentPage;

  void setDepositItemPage(UserScoreDepositPageEntity? pageEntity){
    this._depositPage = pageEntity;
    this._currentPage = pageEntity!.current;
    if(pageEntity.current==1) {
      this._list = pageEntity!.records;
    }else{
      for(int i =0; i < pageEntity.records!.length; i++){
        UserScoreDepositEntity item = pageEntity.records!.elementAt(i);
        this._list!.add(item);
      }
    }
    this._stateType = StateType.empty;
    notifyListeners();
  }

}